package com.inheritancedemo;
class Animal{
    public String name;
    public int age;
    public String sex;

    public void eat(){
        System.out.println(this.name+"cat::eat()!");
    }
    public void sleep(){
        System.out.println(this.name+"睡觉！");
    }
}

/**
 * 继承  其实就是对共性的抽取  从而达到了代码的复用
 */
class Cat extends Animal{



    public void mew(){
        System.out.println(this.name+"cat::mew()!");
    }
}
class Dog extends Animal{

    public void bark(){
        System.out.println("dog::bark()!");
    }
}

public class TestDemo {
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.name = "咪咪";
        cat.sleep();
        cat.eat();
        cat.mew();
    }
}
